package com.briup.ch13;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Properties;
import java.util.Set;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/21
 * @Description:
 */
public class Test2 {
    public static void main(String[] args) throws IOException {
        //这种方法可以读取到jar包中的配置文件，但是只能在out目录下运行
        //
        //InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream("jdbc.properties");
        InputStream inputStream = ClassLoader.getSystemResourceAsStream("jdbc.properties");
        Properties properties = new Properties();
        properties.load(inputStream);
        System.out.println(properties.getProperty("url"));
        Set<String> set = properties.stringPropertyNames();
        for (String key : set) {
            System.out.println(key + "=" + properties.getProperty(key));
            inputStream.close();
        }

    }
}
